﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;


namespace Licenta1.RayTracer
{
    public class Colors
    {
        double R, G, B;

        private double inLimit(double x, double min, double max)
        {
            if ( x < min )
                return min;
            else if ( x > max )
                return max;
            else 
                return x;
        }

        public Colors(double R, double G, double B)
        {
            this.R = inLimit(R, 0, 1);
            this.G = inLimit(G, 0, 1);
            this.B = inLimit(B, 0, 1);
        }

        public Color getColor()
        {
                return Color.FromArgb((int)Math.Round(R * 255), (int)Math.Round(G * 255), (int)Math.Round(B * 255));
        }

        public Colors Multiply(Colors color)
        {
            // TODO max is 1.0
            return new Colors(R * color.R, G * color.G, B * color.B);
        }

        public Colors Intensify(double intensity)
        {
            return new Colors(R * intensity, G * intensity, B * intensity);
        }

        public static Colors operator +(Colors a, Colors b)
        {
            return new Colors(a.R + b.R, a.G + b.G, a.B + b.B);
        }

        public static Colors Black
        {
            get { return new Colors(0, 0, 0); }
        }
    }
}
